package com.jash.cardldemo;

import android.animation.Animator;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.graphics.Palette;
import android.support.v7.view.menu.MenuView;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        img = (ImageView) findViewById(R.id.main_img);
        findViewById(R.id.main_card).setOnClickListener(this);
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.aaa);
        Palette palette = Palette.from(bitmap).generate();
        Palette.Swatch swatch = palette.getDarkMutedSwatch();
        TextView text = (TextView) findViewById(R.id.main_text);
        if (swatch != null) {
            text.setBackgroundColor(swatch.getRgb());
            text.setTextColor(swatch.getTitleTextColor());
        }
    }

    @Override
    public void onClick(View view) {
        int cx = img.getWidth();
        int cy = img.getHeight();
        Animator animator = ViewAnimationUtils.createCircularReveal(img, cx, cy, 0, (float) (cx * Math.sqrt(2)));
        animator.setDuration(2000);
        animator.start();
    }
}
